using System;using System.Data;using System.Data.SqlClient;using System.Collections.Generic;namespace MyWeb.Data{	public class NewsDAL : SqlDataProvider	{		#region[News_GetById]		public List<News> News_GetById(string Id)		{			List<Data.News> list = new List<Data.News>();			using (SqlCommand dbCmd = new SqlCommand("sp_News_GetById", GetConnection()))			{				Data.News obj = new Data.News();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.NewsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[News_GetByTop]		public List<News> News_GetByTop(string Top, string Where, string Order)		{			List<Data.News> list = new List<Data.News>();			using (SqlCommand dbCmd = new SqlCommand("sp_News_GetByTop", GetConnection()))			{				Data.News obj = new Data.News();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Top", Top));				dbCmd.Parameters.Add(new SqlParameter("@Where", Where));				dbCmd.Parameters.Add(new SqlParameter("@Order", Order));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.NewsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[News_GetByAll]		public List<News> News_GetByAll(string Lang)		{			List<Data.News> list = new List<Data.News>();			using (SqlCommand dbCmd = new SqlCommand("sp_News_GetByAll", GetConnection()))			{				Data.News obj = new Data.News();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Lang", Lang));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.NewsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[News_Paging]
        public List<News> News_Paging(string CurentPage, string PageSize, string Fields, string Filter, string Sort)		{			List<Data.News> list = new List<Data.News>();			using (SqlCommand dbCmd = new SqlCommand("sp_News_Paging", GetConnection()))			{				Data.News obj = new Data.News();				dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@CurentPage", CurentPage));				dbCmd.Parameters.Add(new SqlParameter("@PageSize", PageSize));
                dbCmd.Parameters.Add(new SqlParameter("@Fields", Fields));
                dbCmd.Parameters.Add(new SqlParameter("@Filter", Filter));
                dbCmd.Parameters.Add(new SqlParameter("@Sort", Sort));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.NewsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}		return list;		}		#endregion		#region[News_Insert]		public bool News_Insert(News data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_News_Insert", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Name", data.Name));				dbCmd.Parameters.Add(new SqlParameter("@Tag", data.Tag));				dbCmd.Parameters.Add(new SqlParameter("@Image", data.Image));				dbCmd.Parameters.Add(new SqlParameter("@Content", data.Content));				dbCmd.Parameters.Add(new SqlParameter("@Detail", data.Detail));				dbCmd.Parameters.Add(new SqlParameter("@Date", data.Date));				dbCmd.Parameters.Add(new SqlParameter("@Title", data.Title));				dbCmd.Parameters.Add(new SqlParameter("@Description", data.Description));				dbCmd.Parameters.Add(new SqlParameter("@Keyword", data.Keyword));				dbCmd.Parameters.Add(new SqlParameter("@Index", data.Index));				dbCmd.Parameters.Add(new SqlParameter("@Active", data.Active));				dbCmd.Parameters.Add(new SqlParameter("@GroupNewId", data.GroupNewId == "" || data.GroupNewId == "0" ? DBNull.Value : (object)data.GroupNewId));				dbCmd.Parameters.Add(new SqlParameter("@View", data.View));				dbCmd.Parameters.Add(new SqlParameter("@Lang", data.Lang));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("News");			return true;		}		#endregion		#region[News_Update]		public bool News_Update(News data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_News_Update", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", data.Id));				dbCmd.Parameters.Add(new SqlParameter("@Name", data.Name));				dbCmd.Parameters.Add(new SqlParameter("@Tag", data.Tag));				dbCmd.Parameters.Add(new SqlParameter("@Image", data.Image));				dbCmd.Parameters.Add(new SqlParameter("@Content", data.Content));				dbCmd.Parameters.Add(new SqlParameter("@Detail", data.Detail));				dbCmd.Parameters.Add(new SqlParameter("@Date", data.Date));				dbCmd.Parameters.Add(new SqlParameter("@Title", data.Title));				dbCmd.Parameters.Add(new SqlParameter("@Description", data.Description));				dbCmd.Parameters.Add(new SqlParameter("@Keyword", data.Keyword));				dbCmd.Parameters.Add(new SqlParameter("@Index", data.Index));				dbCmd.Parameters.Add(new SqlParameter("@Active", data.Active));				dbCmd.Parameters.Add(new SqlParameter("@GroupNewId", data.GroupNewId == "" || data.GroupNewId == "0" ? DBNull.Value : (object)data.GroupNewId));				dbCmd.Parameters.Add(new SqlParameter("@View", data.View));				dbCmd.Parameters.Add(new SqlParameter("@Lang", data.Lang));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("News");			return true;		}		#endregion		#region[News_Delete]		public bool News_Delete(string Id)		{			using (SqlCommand dbCmd = new SqlCommand("sp_News_Delete", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("News");			return true;		}		#endregion	}}